package com.bloveoacom.weichi.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.AppUtils;
import com.bloveoacom.base.BaseActivity;
import com.bloveoacom.util.Constant;
import com.bloveoacom.util.DisplayUtil;
import com.bloveoacom.util.NumberUtil;
import com.bloveoacom.util.StringUtils;
import com.bloveoacom.util.ToastUtil;
import com.bloveoacom.weichi.R;
import com.bloveoacom.weight.LlkjToolBar;
import com.bloveoacom.weight.ProgressWebView;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * author: yjl
 * e-mail: 1271901673@qq.com
 * time  : 2018/9/21
 * desc  :
 */
public class WebViewActivity extends BaseActivity {
    @BindView(R.id.title_bar)
    LlkjToolBar mToolbar;
    @BindView(R.id.webview_url)
    ProgressWebView webView;
    //内容
    private String data;
    //标题
    private String title;
    //内容类型
    private String datatype;


    @Override
    public int getLayoutResId() {
        return R.layout.activity_webview;
    }

    @Override
    protected View getViewSetTB() {
        return mToolbar;
    }

    @Override
    public void initView() {
        mToolbar.setToolBar(title,
                true, "", R.drawable.ic_back, false, "", LlkjToolBar.isNull);
        switch (NumberUtil.getIntByStr(datatype)) {
            case 0:
                webView.getSettings().setTextZoom(DisplayUtil.sp2px(this,80));
                webView.loadUrl(data);
                break;
            case 1:
                webView.loadData(data,"text/html; charset=UTF-8", null);
                break;
        }
    }

    @Override
    public void initData() {

    }

    @Override
    public void getBundleExtras(Bundle extras) {
        title = extras.getString(Constant.DATA0);
        datatype = extras.getString(Constant.DATA1);
        data = extras.getString(Constant.DATA2);
    }

    @Override
    public void initListener() {

    }

    @Override
    public void onResume() {
        super.onResume();
        if (webView != null) {
            webView.onResume();
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        if (webView != null) {
            webView.onPause();
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (webView != null) {
            webView.destroy();
        }
    }
}
